<?php
namespace Teacher\Controller;
use Admin\Controller\AdminbaseController;
class SingleController extends AdminbaseController {
	
	protected $m;
	
	function _initialize() {
		parent::_initialize();
		$this->m = M('YgclWork');
	}
	
    public function index(){
    	$this->uid = $this->curUser['uid'];
    	$this->cid = I('cid');
    	$this->info = $this->m->where(array('cid'=>$this->cid,'type'=>'course'))->order('id desc')->find();
		$this->display();
    }
    
    public function edit_post(){
    	if(IS_POST){
    		$_POST['update_time'] = Date('Y-m-d H:i:s');
    		if($_POST['id']){
    			$this->m->create();
    			if($this->m->save()){
    				$this->success('更新成功');
    			}else{
    				$this->error('更新失败');
    			}
    		}else{
    			$_POST['create_time'] = Date('Y-m-d H:i:s');
    			$this->m->create();
    			$id = $this->m->add();
    			if($id){
    				$this->success('保存成功');
    			}else{
    				$this->error('保存失败');
    			}
    		}
    	}
    }
}